package com.qf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.mapper.StudentMapper;
import com.qf.pojo.Student;
import com.qf.service.StudentService;
import com.qf.utils.MapperUtils;

import java.util.List;

public class StudentServiceImpl implements StudentService {
    @Override
    public List<Student> findAll() {

        StudentMapper studentMapper = MapperUtils.getMapper(StudentMapper.class);

        List<Student> stus = studentMapper.findAll();

        MapperUtils.close();

        return stus;
    }

    @Override
    public PageInfo<Student> findPage(int pageNum, int size) {

        //设置分页参数
        PageHelper.startPage(pageNum,size);

        //查询
        StudentMapper studentMapper = MapperUtils.getMapper(StudentMapper.class);
        List<Student> stus = studentMapper.findAll();
        MapperUtils.close();

        //返回封装体
        return new PageInfo<>(stus);
    }
}
